from rest_framework import serializers
from .models import Area
#省的数据
class AreaSerializer(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ['id','name']
#市区县的数据
class AreaSubSerializer(serializers.ModelSerializer):
    # areas = [Area,Area..] 在模型中也需要进行序列化器转换
    # AreaSerializer(areas,many=True)
    subs = AreaSerializer(many=True)
    class Meta:
        model = Area
        fields = ['id','name','subs']

